# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

_hkgname=tls
pkgname=haskell-tls
pkgver=1.6.0
pkgrel=33
pkgdesc="TLS/SSL protocol native implementation (Server and Client)"
url="https://github.com/vincenthz/hs-tls"
license=("BSD")
arch=('loong64' 'x86_64')
depends=('ghc-libs' "haskell-asn1-encoding" "haskell-asn1-types" "haskell-async" "haskell-cereal"
         "haskell-cryptonite" "haskell-data-default-class" 'haskell-hourglass' "haskell-memory"
         "haskell-network" "haskell-x509" "haskell-x509-store" "haskell-x509-validation")
makedepends=('ghc' 'haskell-quickcheck' 'haskell-tasty' 'haskell-tasty-quickcheck')
source=("https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz")
sha512sums=('e962c6600504ea2e1f701ed4488f30aff71fa52986b35091c6105ab8e26f02532e81bd6af5e8396f0b5d51fae4c4f1c4015211deb27d8a212dfd60f84b00ede8')

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
            -f-hans -fnetwork -fcompat
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
